package com.huitone.gddw.service.dto;

import com.huitone.gddw.common.excel.ColToProperty;
import com.huitone.gddw.common.excel.TabCol;
import com.huitone.gddw.dao.entity.ForbidRule;

/**
 * 禁发时段规则 DTO 对象
 * @author wuluodan
 *
 */
public class ForbidRuleDTO {

	@ColToProperty
	@TabCol(Index = 1, title = "序号", width = "")
	private Integer seq;
	
	private String forbidRuleId;
	
	@ColToProperty
	@TabCol(Index = 2, title = "禁发时段规则名称", width = "105")
	private String forbidRuleName;
	
	@ColToProperty
	@TabCol(Index = 3, title = "业务端名称", width = "90")
	private String svrNodeName;
	
	private String svrNode;
	
	@ColToProperty
	@TabCol(Index = 4, title = "短信类型名称", width = "90")
	private String serviceName;
	
	private String serviceCode;
	
	private Float startTime;
	
	@ColToProperty
	@TabCol(Index = 5, title = "禁发开始时间", width = "75")
	private String startTimeStr;

    private Float endTime;
	
    @ColToProperty
	@TabCol(Index = 6, title = "禁发结束时间", width = "75")
	private String endTimeStr;
    
    private String status;
    
    @ColToProperty
	@TabCol(Index = 7, title = "状态", width = "")
    private String statusStr;
    
    @ColToProperty
	@TabCol(Index = 8, title = "说明", width = "150")
    private String desc;

    public ForbidRuleDTO() {}
    
    public ForbidRuleDTO(ForbidRule entity) {
    	this.setForbidRuleId(entity.getForbidRuleId());
    	this.setForbidRuleName(entity.getForbidRuleName());
    	this.setSvrNode(entity.getSvrNode());
    	this.setServiceCode(entity.getServiceCode());
    	this.setStartTime(entity.getStartTime());
    	this.setEndTime(entity.getEndTime());
    	this.setStatus(entity.getStatus());
    	this.setDesc(entity.getDesc());
    }
    
	public Integer getSeq() {
		return seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}

	public String getForbidRuleId() {
		return forbidRuleId;
	}

	public void setForbidRuleId(String forbidRuleId) {
		this.forbidRuleId = forbidRuleId;
	}

	public String getForbidRuleName() {
		return forbidRuleName;
	}

	public void setForbidRuleName(String forbidRuleName) {
		this.forbidRuleName = forbidRuleName;
	}

	public String getSvrNodeName() {
		return svrNodeName;
	}

	public void setSvrNodeName(String svrNodeName) {
		this.svrNodeName = svrNodeName;
	}

	public String getSvrNode() {
		return svrNode;
	}

	public void setSvrNode(String svrNode) {
		this.svrNode = svrNode;
	}

	public String getServiceName() {
		return serviceName;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	public String getServiceCode() {
		return serviceCode;
	}

	public void setServiceCode(String serviceCode) {
		this.serviceCode = serviceCode;
	}

	public Float getStartTime() {
		return startTime;
	}

	public void setStartTime(Float startTime) {
		this.startTime = startTime;
	}

	public String getStartTimeStr() {
		if (null == this.startTime) return "";
		return this.startTime.intValue() + ":" + getMin(this.startTime);
	}

	public void setStartTimeStr(String startTimeStr) {
		this.startTimeStr = startTimeStr;
	}

	public Float getEndTime() {
		return endTime;
	}

	public void setEndTime(Float endTime) {
		this.endTime = endTime;
	}

	public String getEndTimeStr() {
		if (null == this.endTime) return "";
		return this.endTime.intValue() + ":" + getMin(this.endTime);
	}

	public void setEndTimeStr(String endTimeStr) {
		this.endTimeStr = endTimeStr;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getStatusStr() {
		if (null == this.status) {
			return "未知";
		}
		if (this.status.equals("1")) {
			return "有效";
		}
		if (this.status.equals("0")) {
			return "失效";
		}
		return "未知";
	}

	public void setStatusStr(String statusStr) {
		this.statusStr = statusStr;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}
	
	/**
	 * 获取时间的分钟数
	 * @param time 时间
	 * @return String 分钟数
	 */
	private String getMin(Float time) {
		String arr[] = String.valueOf(time).split("\\.");
		if (arr.length < 2) {
			return "00";
		}
		Double minD = Math.ceil(Double.valueOf("0." + arr[1]) * 60);
		String min = minD.intValue() < 10 ? "0" + minD.intValue() : String.valueOf(minD.intValue());
		return min;
	}
	
}
